package com.my.test.common;

import org.apache.ibatis.session.ExecutorType;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.MyBatisExceptionTranslator;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.dao.support.PersistenceExceptionTranslator;

public class CustomSqlSessionTemplate extends SqlSessionTemplate{

	public CustomSqlSessionTemplate(SqlSessionFactory sqlSessionFactory) {

	    this(sqlSessionFactory, sqlSessionFactory.getConfiguration().getDefaultExecutorType());

	}


	public CustomSqlSessionTemplate(SqlSessionFactory sqlSessionFactory, ExecutorType executorType) {

	    this(sqlSessionFactory, executorType, new MyBatisExceptionTranslator(sqlSessionFactory.getConfiguration()

	            .getEnvironment().getDataSource(), true));

	}



	public CustomSqlSessionTemplate(SqlSessionFactory sqlSessionFactory, ExecutorType executorType,

	        PersistenceExceptionTranslator exceptionTranslator) {



	    super(sqlSessionFactory, executorType, exceptionTranslator);



//	    this.sqlSessionFactory = sqlSessionFactory;
//
//	    this.executorType = executorType;
//
//	    this.exceptionTranslator = exceptionTranslator;
//
//	     
//
//	    this.sqlSessionProxy = (SqlSession) newProxyInstance(
//
//	            SqlSessionFactory.class.getClassLoader(),
//
//	            new Class[] { SqlSession.class },
//
//	            new SqlSessionInterceptor());
//
//
//
//	    this.defaultTargetSqlSessionFactory = sqlSessionFactory;

	}
}
